-
Notifications
You must be signed in to change notification settings - Fork 27
implement match for generate.yaml #483
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Should we also allow this on the answer files? to ensure a testcase is (im)possible as intended. |
|
Consider bumping the generator framework version. The sample and the default in the CUE schema |
But Hm. I find this useful, but now it’s getting ugly. An idea for syntax that is consistent with the current proposal: I guess the schema is match: string | [...string] | {
in: string | [...string]
ans: string | [...string]
} |
|
even though this might be less yaml like i would prefer to not nest these and go for something like |
|
Just be make sure I was clear: I propose to retain as a valid expression, and expect it to be the widest-used form. I propose that the above is the same as (which, thanks to standard YAML syntax, can also be written as a one-liner, The situation in which the “mapping” form would mainly arise is when you want to specify something about I would advise against introducing more keys in the top-level mapping (such as The main alternatives I can see to my proposal would be to add [in|ans]: string | {
value: string
pattern: string | [...string]
}so you’d have expressions like this: This doesn’t smell right to me, but it’s just a hunch. |
|
I notice that we already have a plethora of stuff, namely The current semantics is that the key: value pair means " This is a case against introducing keys like My hunch is that the cleanest way is to enrich the right-hand side, instead of introducing more left-hand sides of such expressions. I think what I’m saying is allowing in: foo
match:
ans.statement: \d\w+ Alternatively, in: foo
ans.statement:
match: \d\w+ Dream state The dream state would be what CUE already supports out-of-the box: ans: "impossible" # ans must equal impossible
---
in: number & >0 # in must be a number, and strictly larger than 0
---
ans: "yes" | "no" # ans must be either "yes" or "no"
in.statement: =~"^\w\w$" # in.statement has two letters
in: !~"impossible" # in does not contain impossible
in: in.statement # in and in.statement are identicalIn other words, there’s a whole grammar on the right hand side supporting Note that explicit creation and constraint checking are the same: CUE just unifies everything it knows about, say This would be sah-weet! |
|
Interesting idea to do Should it be |
I don't like that, also feels weird in combination with generated testcases...
I dont think we need this for something else as
Unmatch would certainly be nice...
I am fine with that, even though I like to not nest things... :D The question is if/how we want to support unmatch than? |
The current proposal already supports “unmatching”, since regexen support that. Here are the three examples from upthread again, for a problem with output CUE of course would make this nicer to look at: |
I don't think that one is right? ( |
|
The only thing I’m unsure about for my negative lookahead regex is what do to with a possibly trailing newline. (I don’t understand the specification well enough.) So maybe it should be |
|
I think the issue is that we don't do a full match but a search, and you pattern still matches a suffix not containing impossible? Anyway: yes it can be expressed... the question is do we want simpler syntax for this? ^^' |
Now I understand. That’s what |
|
but |
|
Hear me out. This actually works:
Do allow certain CUE-expressions as the right hand sides of For instance, we can do in: "impossible" # just like we always have
---
in: =~"\\d\\d" # two digits
---
in: "foo" | "bar"
---
in: "^[a-z]+$" & !~"^impossible$" # alphabetic word, but not impossible and a thousand other things. CUE is quite expressive. The main use case are disjuntions and regex match and unmatch. What is new is that the right hand side is now a constraint. If no
For a generator rule, various files can be created. Whatever has been produced (maybe nothing) is now unified using CUE and produce a concrete value (i.e., a concrete means that “the output of the default submissions will be unified with But if we had the output of the default submission could be
The CUE CLI already does this. You can set up a very small CUE snippet: input: string // will be filled from CLI with concrete value
expr: "foo" | "bar" // the value of an ans-key in generators.yaml
ok: input & expr
The only reason to not do this is that it increases the dependencies of BAPCtools. (Which is a good enough reason, I think.) Still, cool AF. Backwards compatible. |
|
I actually don't understand what you want to suggest? ^^' suppose one of your examples is the actual what is supposed to happen (in our implementation)? do we first run cue on the yaml? do we parse the yaml? |
solves #312
@thorehusfeldt do you mind adjusting the schemas?